<template>
    <div>
        <eagle-dialog title="选择预案类型" @confirm="confirm" @open="onOpen" ref="eagleDialog" v-bind="$attrs" v-on="$listeners">
            <div class="dialog-content-radio">
                <eagle-radio-group v-model="checkType" direction="horizontal">
                    <div
                        v-for="(item, index) in data.PlanTypeList"
                        :key="index"
                        style="margin-bottom: 10px"
                        :style="{ width: (item.ID && item.ID!='0') ? '50%' : '100%' }"
                        >
                        <eagle-radio v-if="item.ID && item.ID!='0'" :name="item.ID">
                            <span style="font-size: 14px">{{ item.Name }}</span>
                        </eagle-radio>
                        <div v-else>
                            <eagle-radio :name="item.ID">
                                <span style="font-size: 14px">{{ item.Name }}</span>
                            </eagle-radio>
                            <eagle-input label="" v-model="checkTypeName" isInputText></eagle-input>
                        </div>
                    </div>
                </eagle-radio-group>
            </div>
        </eagle-dialog>
    </div>
</template>
<script>
//选择检查类型弹框
import eagleRadio from '../../../components/eagle/eagle-radio.vue';
export default {
  components: { eagleRadio },
    name:"check-type-dialog",
    props:{
        data: {},
    },
    data(){
        return {
            checkType: "",
            checkTypeName: "",
        }
    },
    methods:{
        confirm(){
            
            let result = "";
            if (this.checkType!=undefined) {
                if (this.checkType != "0") {
                    result = this.checkType;
                } else {
                    result = "Custom-" + this.checkTypeName;
                }
                this.$emit("close", result);
            }
        },
        onOpen() {
            
            if (this.data.CheckType) {
                if (this.data.CheckType.indexOf("Custom")>=0) {
                    this.checkType = "0";
                    this.checkTypeName = this.data.CheckType.substring(7);
                } else {
                    this.checkType = this.data.CheckType;
                    this.checkTypeName = "";
                }
            }
        },
    }
}
</script>
<style lang="less" scoped>
.dialog-content-radio {
    padding: 0 15px;
}
</style>